package com.itheima.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 自定义springboot配置类
@Configuration
public class MyWebConfig implements WebMvcConfigurer {


    // 添加注册拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(new TokenInterceptor())
                .addPathPatterns("/**") // 拦截所有请求
                .excludePathPatterns("/login"); // 放行 / 和 /login请求,
        // 因为例子写的比较简单
        // .excludePathPatterns("/","/login","/css/**","/js/**","/fonts/**","/images/**"); 平常可以写这样
    }
}
